#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stack>
using namespace std;

struct BTNode
{
	int _data;
	BTNode* _left;
	BTNode* _right;
};

BTNode* TreeCreat()
{
	int k;
	scanf("%d", &k);
	if (k == 0)
		return NULL;
	BTNode* root = new BTNode;
	root->_data = k;
	root->_left = TreeCreat();
	root->_right = TreeCreat();
	return root;
}

stack<BTNode*> longest;
stack<BTNode*> tmp;
int len = 0;
int longestlen = 0;
void longestPath(BTNode* root)
{
	if (root == nullptr)
		return;
	if (root->_left && root->_right)
	{
		tmp.push(root);
		if (len > longestlen)
		{
			while (tmp.empty())
			{
				longest.push(tmp.top());
				tmp.pop();
				longestlen = len;
			}
		}
	}
	else
	{
		tmp.push(root);
		longestPath(root->_left);
		longestPath(root->_right);
		len--;
	}
}

int main()
{
	return 0;
}

void createCSTree_Degree(CSTree*& T, int data[], int degree[], int n) 
{

	CSTree** temp = (CSTree**)malloc(sizeof(CSTree) * n);
	for (int i = 0; i < n; i++) 
	{ 
		temp[i] = (CSTree*)malloc(sizeof(CSTree));
		temp[i]->data = data[i];
		temp[i]->lchild = temp[i]->sright = NULL; 

	}
	int index = 1; 
	int d;
	for (int j = 0; j < n; j++) 
	{
		d = degree[j];

		if (d) 
		{
			temp[j]->lchild = temp[index]; 

			for (int k = 2; k <= d; k++) 
			{ 
				index++;
				temp[index - 1]->sright = temp[index]; 
			}
		}

	}
	T = *temp;
}